# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=rdflib
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=7.1.4
pkgrel=1
pkgdesc='A Python library for working with RDF, a simple yet powerful language for representing information (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/rdflib'
  "cpe: cpe:/a:rdflib_project:rdflib"
)
msys2_repository_url='https://github.com/RDFLib/rdflib'
url='https://rdflib.readthedocs.io/'
license=('spdx:BSD-3-Clause')
options=(!strip)
depends=("${MINGW_PACKAGE_PREFIX}-python-isodate"
         "${MINGW_PACKAGE_PREFIX}-python-pyparsing")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-poetry-core")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('fed46e24f26a788e2ab8e445f7077f00edcf95abb73bcef4b86cefa8b62dd174')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/python -m pytest
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
